package com.deprice4u_client;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

;

public class GroupPurchaseDetail extends Activity {

	GroupPurchase gp;
	String userId;
	String userEmail;
	int userDeposit;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.gp_detail);

		Intent intent = getIntent();
		String gpInfoStr = intent.getStringExtra("gp");

		GroupPurchase gp = new GroupPurchase(gpInfoStr);
		SharedPreferences userInformation = getSharedPreferences(Preference.PREFS_NAME, 0);
		userId = userInformation.getString(Preference.USER_ID, "null");
		userEmail = userInformation.getString(Preference.EMAIL, "");
		userDeposit = userInformation.getInt(Preference.DEPOSIT, 0);
		
		//현재 user 정보를 받아오는데, 아이디와 이메일 디파짓만 받아옵니다.
		//user 정보 받아오는데는 DePrice4U_clientActiviry에서 받아옵니다.

		// gp받아와서 초기화 시켜야되
		TextView title = (TextView) findViewById(R.id.title_gp_detail);
		title.setText(gp.title);

		ImageView imageView = (ImageView) findViewById(R.id.iv_gp_detail);
		DrawableManager dm = new DrawableManager();
		dm.fetchDrawableOnThread(gp.imgUrl, imageView);

		TextView lowestPrice = (TextView) findViewById(R.id.lowest_price_gp_detail);
		lowestPrice.setText(gp.lowestPrice);

		TextView participantsNumber = (TextView) findViewById(R.id.number_of_users_gp_detail);
		int numberOfParticipants = Integer.valueOf(gp.numberOfUsersWithDeposit)
				+ Integer.valueOf(gp.numberOfUsersWithoutDeposit);
		participantsNumber.setText(String.valueOf(numberOfParticipants));

		TextView tagLowestPrice = (TextView) findViewById(R.id.tag_lowest_price_gp_detail);
		TextView tagParticipantsNumber = (TextView) findViewById(R.id.tag_number_of_users_gp_detail);
		TextView tagDescription = (TextView) findViewById(R.id.tag_description_gp_detail);

		TextView description = (TextView) findViewById(R.id.description_gp_detail);
		description.setText(gp.description);

	}

	// join this request
	public void onClickJoinButtion(View view) {

	}
}
